package com.community.backend.controller;

import com.community.backend.utils.Result;
import com.community.backend.utils.TencentCosUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/common")
public class CommonController {
    @Resource
    private TencentCosUtil tencentCosUtil;

    /**
     * 文件上传
     */
    @PostMapping("/upload")
    //@ApiOperation("文件上传")
//    @Operation(summary = "文件上传")
    public String upload(MultipartFile file) {
        log.info("上传文件：{}", file);
        log.info("正在上传，文件名{}",file.getOriginalFilename());
        String url = tencentCosUtil.upLoadFile(file);
        log.info("文件的Url：{}",url);
        return url;
    }
}
